<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!doctype html>
<html class="no-js">
<head>
    <%@ include file="./../common/meta.jsp" %>
    <link rel="stylesheet" href="../../css/store.css">
</head>
<body>
<header data-am-sticky class="am-header am-header-default am-no-layout">
    <div class="am-header-left am-header-nav">
        <a href="./store.jsp" class="">
            <i class="am-header-icon am-icon-chevron-left"></i>
        </a>
    </div>
    <h1 class="am-header-title">好店</h1>
</header>

<div class="am-content">

    <div data-am-widget="slider" class="am-slider am-slider-default" data-am-slider='{}'>
        <ul class="am-slides">
        </ul>
    </div>

    <div data-am-widget="titlebar" class="am-titlebar am-titlebar-cols">
        <nav class="am-titlebar-nav">
            <a href="#c1" class="search" type="1">好评优先</a>
            <a href="#c2" class="search" type="2">促销优先</a>
            <a href="#c3" class="search" type="3">价格优先</a>
        </nav>
    </div>


    <div data-am-widget="list_news" class="am-list-news am-list-news-default">
        <div class="am-list-news-bd">
            <ul class="am-list" id="haodian-list">


            </ul>
        </div>

    </div>


</div>


<%@ include file="./../common/footerNav.jsp" %>
<%@ include file="./../common/footer.jsp" %>
<script src="../../js/store/store-list.js"></script>


<script id="banner-template" type="text/x-handlebars-template">
    {{#each banners}}
    <li>
        <a href="{{link}}" target="_blank">
            <img src="{{../baseUrl}}{{picture}}" style="height: 200px">
        </a>

    </li>
    {{/each}}
</script>

<script id="haodian-list-template" type="text/x-handlebars-template">
    {{#each list}}
    <li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left">
        <div class="am-u-sm-4 am-list-thumb">
            <a href="./store-detail.jsp?id={{id}}&&catId={{catlogid}}" class="">
                <img src="{{shopheadimage}}"/>
            </a>
        </div>

        <div class=" am-u-sm-8 am-list-main">
            <h3 class="am-list-item-hd"><a href="./store-detail.jsp?id={{id}}&&catId={{catlogid}}"
                                           class="">{{shopname}}</a></h3>

            <div class="am-list-item-text">
                {{catLogName}}
            </div>

            <div class="am-list-item-text">
                距离:{{distance}}km
            </div>

            <div class="am-list-item-text">
                评价数:{{commentCounts}} 满意数:{{hcommentCounts}} 满意度:{{myd}}
            </div>

            <div class="am-list-item-text">
                等级:暂无
            </div>


        </div>
    </li>
    {{/each}}
</script>


<script>

    $(function () {

        var catId = "<%=request.getParameter("catId")%>";

        var user = JSON.parse(localStorage.getItem("user"));
        if (user == null || user == "null") {
            window.location.href = './login/login.jsp';

        }
        var url = "/h5GoodShop/getGoodShopByCatlog?catlogid=" + catId + "&accountId=" + user.id + "&shoptype=1";
        $.post(url, function (result) {
            var source = $('#haodian-list-template').html();
            var template = Handlebars.compile(source);
            var html = template(result);
            $("#haodian-list").append(html);
        });


        var url1 = "/h5GoodShop/bannerList";
        $.post(url1, function (result) {

            var source = $('#banner-template').html();
            var template = Handlebars.compile(source);
            var html = template(result);
            $(".am-slides").append(html);
            $('.am-slider').flexslider();
        });


        $(".search").click(function () {

            var type = $(this).attr("type");
            var catId = "<%=request.getParameter("catId")%>";
            var url = "/h5GoodShop/getGoodShopByCatlog?catlogid=" + catId + "&shoptype=" + type + "&accountId=" + user.id;
            $.post(url, function (result) {
                $("#haodian-list").empty();
                var source = $('#haodian-list-template').html();
                var template = Handlebars.compile(source);
                var html = template(result);
                $("#haodian-list").append(html);
            });
        })


    })


</script>


</body>


</html>